package com.ai.wx.service;

import java.util.Date;

import com.ai.core.pagemode.Grid;
import com.ai.core.pagemode.Json;
import com.ai.core.pagemode.PageFilter;
import com.ai.wx.entity.AgentBrokerage;
import com.ai.wx.entity.AgentBrokerageDraw;
import com.ai.wx.entity.AgentPromotion;
import com.ai.wx.entity.AgentUser;
import com.ai.wx.entity.PromotionCodeRes;
import com.ai.wx.exception.FlowMarketException;

public interface AgentService {

	/**
	 * 代理商用户名是否被占用
	 * @param agentUser
	 * @return
	 */
	public boolean isExistAgentUser(String agentUser);

	/**
	 * 是否已经是代理商用
	 * @param agentUser
	 * @return
	 */
	public boolean isAgentUser(String openId);
	/**
	 * 注册代理商
	 * @param agentUser
	 * @param agentAccount
	 * @throws Exception
	 */
	public Json registerAgentUser(AgentUser agentUser);

	/**
	 * 预占优惠码
	 * @param ownAgentId
	 * @return
	 */
	public PromotionCodeRes preOccupyPromCode(int ownAgentId);

	/**
	 * 生成优惠折扣码
	 * @param agentPromoiton
	 * @throws FlowMarketException
	 */
	public void occupyPromCode(AgentPromotion agentPromoiton) throws FlowMarketException;

	/**
	 * 代理商登陆
	 * @param agentUser
	 * @param password
	 * @return
	 */
	public Json agentLogin(String agentUser, String password);

	/**
	 * 佣金提取申请
	 * @param draw
	 * @throws FlowMarketException
	 */
	public Json applyDrawBrokerage(AgentBrokerageDraw draw) throws FlowMarketException;

	
	/**
	 * 获取代理商佣金
	 * @param agentId
	 * @return
	 */
	public AgentBrokerage getAgentBrokerage(Integer agentId);
	

	public Long getBrokerageCount(Integer agentId);
	
	/**
	 * 获取代理商佣金明细
	 * @param agentId
	 * @return
	 */
	public Grid getAgentBrokerageDtl(Integer agentId,PageFilter page);
	

	
	/**
	 * 获取代理商佣金提取记录
	 * @param agentId
	 * @param page
	 * @param rows
	 * @return
	 */	
	public Grid getAgentBrokerageDraw(Integer agentId, Integer drawState, Date startDate, Date endDate,PageFilter page);

	/**
	 * 根据openid获取代理商信息
	 * @param openId
	 * @return
	 */
	public AgentUser getAgentUserByOpenId(String openId);

	public AgentPromotion buyAgentPromoiton(Integer agentId);
	

	public void setAgentPromoiton(Integer agentId,Integer promotionRate)throws FlowMarketException;
}
